package com.server.pojo;

import com.server.pojo.base.PojoBase;
import lombok.*;
import lombok.experimental.Accessors;
import org.hibernate.Hibernate;

import javax.persistence.*;
import java.util.Objects;

@Getter
@Setter
@ToString

@Entity
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Table
public class MobileAppUnit extends PojoBase {

    @ManyToOne
    MobileApp mobileApp;

    @ManyToOne
    Unit unit;



    @PrePersist
    public void prePersist(){
    }

    @PreUpdate
    public void preUpdate(){

    }
    @PreRemove
    public void preRemove(){

    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
        MobileAppUnit that = (MobileAppUnit) o;
        return getId() != null && Objects.equals(getId(), that.getId());
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }
}
